﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace KingCat_Log
{
    /// <summary>
    /// 系统日志处理类
    /// </summary>
    public class WriteLog
    {
        private static WriteLog wl;
        private StreamWriter sw;
        private string path;
        private WriteLog()
        {
            path = Directory.GetCurrentDirectory();
            path = path.Substring(0, path.LastIndexOf("\\"));
            path = path.Substring(0, path.LastIndexOf("\\"));
            path += "\\log.txt";
        }

        public static WriteLog getInstance()
        {
            if (wl == null)
            {
                wl = new WriteLog();
            }
            return wl;
        }

        public void writeLog(String s)
        {
            sw = new StreamWriter(path, true, Encoding.UTF8);
            sw.WriteLine(s);
            sw.Flush();
            sw.Close();
        }
    }
}
